package com.example.jiagoujiexiang.Service.impl;

import com.example.jiagoujiexiang.Mapper.petDao;
import com.example.jiagoujiexiang.Mapper.subscribeDao;
import com.example.jiagoujiexiang.Service.adminService;
import com.example.jiagoujiexiang.Service.subService;
import com.example.jiagoujiexiang.entity.User;
import com.example.jiagoujiexiang.entity.subscribe;
import com.example.jiagoujiexiang.Mapper.subscribeDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class subServiceimpl implements subService {

    private final subscribeDao subDao;
    @Autowired
    public subServiceimpl(subscribeDao subDao) {
        this.subDao = subDao;
    }
    @Cacheable(cacheNames = "SubList")
    @Override
    public List<subscribe> getSubServiceList() {
        return subDao.getSubscribeList();
    }

    @Override
    public int addSubService(subscribe subscribe) {
        return subDao.addSubscribe(subscribe);
    }
    @CacheEvict(cacheNames = "SubList", allEntries = true)
    public int deleSubscribe(int pet_id){
        return subDao.deleSubscribe(pet_id);
    }
    @CachePut(cacheNames = "Subscribe",key = "#subscribe.user_id")
    @Override
    public int updateSubscribe(subscribe subscribe) {
        return subDao.updateSubscribe(subscribe);
    }
}
